#include <iostream>
#include <iomanip>
using namespace std;

double a1[1001];
double a2[1001];
double res[1001];
int main(){
	freopen("in.txt","r",stdin);
	int k1,k2;
	cin >> k1;
	for(int i=0; i<k1; i++ ){
		int exp;
		double coeff;
		cin >> exp >> coeff;
		a1[exp] = coeff;
	}
	cin >> k2;
	for(int i=0; i<k2; i++ ){
		int exp;
		double coeff;
		cin >> exp >> coeff;
		a2[exp] = coeff;
	}
	int cnt = 0;
	for(int i=0; i<1001; i++ ){
		if( (res[i]=a1[i]+a2[i])!=0 ) cnt++;
	}
	cout << cnt;
	for(int i=1000; i>-1; i--){
		if( res[i]!=0 ) cout<< " " <<i<<" "<<fixed<<setprecision(1)<<res[i];
	}
	return 0;
}
